<template>
  <div id="main6"></div>
</template>

<script>
import * as echarts from 'echarts';

export default {
  props:['data'],
  data() {
    return {}
  },
  mounted() {
  },
  methods:{
    initEcharts(data, labels) {
      const chartDom = document.getElementById('main6')
      const myChart = echarts.init(chartDom)
      let option

      option = {
        grid:{
          bottom:'10%'
        },
        tooltip: {
          trigger: 'item'
        },
        xAxis: {
          type: 'category',
          data:labels
        },
        yAxis: {
          type: 'value'
        },
        color:"#108af1",
        series: [
          {
            data: data,
            type: 'bar'
          }
        ]
      };

      option && myChart.setOption(option);
    }
  },
  watch:{
    data({data,labels}){
      this.initEcharts(data,labels)
    }
  }
}
</script>

<style scoped>
#main6 {
  width: 100%;
  height: 300px;
}
</style>
